using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Evaluation3.utils;

public partial class cucil_info : System.Web.UI.Page
{
    private String firstStep = "0";
    private String maxStep = "2";

    private decimal totalMax_ = 1;
    private decimal totalMin_ = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            Session[keyUtils.SES_SELECTEDTAB] = "0";
           

        }
        //Response.Write(Request.QueryString["selectedTab"].Trim().Length > 0);
        //Session[keyUtils.SES_SELECTEDTAB] = Request.QueryString["selectedTab"]; 

    }
    protected void changeFilter(object sender,  EventArgs e) {

        if (cb_memberFilter.SelectedValue == null || cb_memberFilter.SelectedValue.Equals("0"))
        {
            //ErrorMessage(cb_memberFilter.SelectedValue.Equals("0").ToString());
            string sql = "select thanhvien.mathanhvien, tenthanhvien,doanhnghiep.MaDoanhNghiep,doanhnghiep.tendoanhnghiep,";

            sql = sql + " hoidongchamdiem.mahoidong, tenvitri from thanhvien inner join doanhnghiep on thanhvien.madoanhnghiep = doanhnghiep.madoanhnghiep";
            sql = sql + " inner join hoidongchamdiem on thanhvien.mathanhvien = hoidongchamdiem.mathanhvien inner join hoidong on hoidong.mahoidong = hoidongchamdiem.mahoidong";
            sql = sql + " inner join vitri on thanhvien.mavitri = vitri.mavitri";
             thanhvienData.SelectCommand = sql;
             thanhvienData.DataBind();
            //memberListData.SelectParameters.
        }
        thanhvienData.DataBind();
      
    }
    protected void changeType(object sender, EventArgs e) {

        if (cb_memberFilterType.SelectedValue.Equals("0")) {
            cb_memberFilter.DataSource = cucilDataFilterList;
           
        }
        else if (cb_memberFilterType.SelectedValue.Equals("1")) {
            cb_memberFilter.DataSource = companyDataFilterList;

        }
        else if (cb_memberFilterType.SelectedValue.Equals("-1"))
        {
            cb_memberFilter.DataSource = new DataView();

        }
        cb_memberFilter.DataBind();
        //ErrorMessage(cb_memberFilter.Items.Count.ToString());
        if ( cb_memberFilter.SelectedValue.Equals("0"))
        {
            
            string sql = "select thanhvien.mathanhvien, tenthanhvien,doanhnghiep.MaDoanhNghiep,doanhnghiep.tendoanhnghiep,";

            sql = sql + " hoidongchamdiem.mahoidong, tenvitri from thanhvien inner join doanhnghiep on thanhvien.madoanhnghiep = doanhnghiep.madoanhnghiep";
            sql = sql + " inner join hoidongchamdiem on thanhvien.mathanhvien = hoidongchamdiem.mathanhvien inner join hoidong on hoidong.mahoidong = hoidongchamdiem.mahoidong";
            sql = sql + " inner join vitri on thanhvien.mavitri = vitri.mavitri where thanhvien.status =1 and doanhnghiep.status=1 and hoidong.status=1";
            thanhvienData.SelectCommand = sql;
            thanhvienData.DataBind();
            //memberListData.SelectParameters.
        }
        thanhvienDataView.DataBind();
        
    }
    protected String getSelectedTab() { return Session[keyUtils.SES_SELECTEDTAB].ToString(); }
    protected void setSelectedTab(String i) { Session[keyUtils.SES_SELECTEDTAB] = i; }
    protected void ChangeTabIndex(object sender, EventArgs e)
    {
        String senderId = ((LinkButton)sender).ID;
        setSelectedTab(senderId.Substring(senderId.Length - 1));
        
    }
    
    
    public void ErrorMessage(String message)
    {
        Controls.Add(new LiteralControl(MessageBox.SHOW(message, MessageBox.INFO)));
    }
    public void setRenderControl(int i)
    {
    }
    protected void resetValue(object sender, EventArgs e)
    {

    }

    public void viewStep(int step)
    {
    }
    protected void backStep(object sender, EventArgs e)
    {
        int tab = Convert.ToInt32(getSelectedTab());
        if (tab > 0) tab--;
        setSelectedTab(tab.ToString());
    }
    protected void nextStep(object sender, EventArgs e)
    {
        int tab = Convert.ToInt32(getSelectedTab());
        if (tab < 1) tab++;
        setSelectedTab(tab.ToString());
    }
    protected void saveWizard(object sender, EventArgs e)
    {
    }

    protected void cancelWizard(object sender, EventArgs e)
    {
        Session[keyUtils.SES_SELECTEDTAB] = "0";
        Response.Redirect("default.aspx");

    }

     
}
